package de.test.selenium.services;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class SeleniumFireFoxExample {

	public void run() {

		WebDriver driver = new FirefoxDriver();

		driver.get("http://www.dvd-palace.de/dvddatenbank.php");

		// Find the text input element by its name
		WebElement element = driver
				.findElement(By.name("suchetitel"));

		// Enter something to search for
		element.sendKeys("4006680070889 ");
	
		 
		 WebElement element2 = driver
			.findElement(By.name("formular"));
		// Now submit the form. WebDriver will find the form for us from the
		// element
 	element2.submit();

		(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
			public Boolean apply(WebDriver d) {
				return true;
			}
		});

		String pageSource = driver.getPageSource();
		System.out.println(pageSource);
	}

	public static void main(String[] args) {
		SeleniumFireFoxExample s = new SeleniumFireFoxExample();
		s.run();
	}
}
